<template>
	<view class="page">
		<view class="wrapper">
			<view class="address-wrapper">
				<image class="img" src="../../static/images/pos.png" mode="aspectFill"></image>
				<view class="right">
					<view class="row">
						<view class="name">
							{{receive_name}}
						</view>
						<view class="tel">
							{{mobile}}
						</view>
					</view>
					<view class="address">
						{{address}}
					</view>
				</view>
				<image class="img right" src="../../static/images/next.png" mode="aspectFill"></image>
			</view>
			
			<my-shopcard
				v-for="i in goods"
				:key="i.id"
				:img="i.full_goods_pic"
				:name="i.goods_name"
				:number="i.num"
				:money="i.single_price"
				:state="1"
			></my-shopcard>
			
			<view class="info-wrapper">
				<view class="info">订单编号：<text class="light">{{order.trade_no}}</text></view>
				<view class="info">创建时间：<text class="light">{{order.created_at}}</text></view>
			</view>
		</view>
		
		<view class="footer">
			<view class="cancel">
				
			</view>
			<view class="right">
				<view class="text">
					合计：
				</view>
				<view class="money">
					￥{{total_price}}
				</view>
				<view class="btn">
					已支付
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				no: '',
				order: '',
				logisticals: '',
				goods: [],
				total_price: '',
				coin_amount: '',
				address: '',
				receive_name: '',
				mobile: '',
				show: false
			}
		},
		onLoad(opt) {
			if (opt.no) {
				this.no = opt.no
				this.getOrder(opt.no)
			}
		},
		onShow() {
			this.getOrder(this.no)
		},
		methods: {
			getOrder(no) {
				this.$u.get('/orders/detail?trade_no=' + no).then(res => {
					console.log(res)
					let data = res.data.result.order
					this.order = data
					this.logisticals = data.logisticals
					this.goods = data.orders_detail
					this.total_price = data.total_price
					this.coin_amount = data.coin_amount
					this.address = data.address
					this.receive_name = data.receive_name
					this.mobile = data.mobile
				})
			},
			goto(path) {
				uni.navigateTo({
					url: path,
					animationType: 'slide-in-right',
					animationDuration: 300
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.address-wrapper {
		color: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 30rpx;
		margin: 30rpx 0 60rpx 0;
		.img {
			width: 50rpx;
			height: 50rpx;
			display: block;
			margin-right: 30rpx;
			flex: 0 0 auto;
			&.right {
				margin-left: 30rpx;
				margin-right: 0;
			}
		}
		.row {
			display: flex;
			justify-content: space-between;
			margin: 20rpx 0;
			font-size: 34rpx;
		}
		.name {
			max-width: 300rpx;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			letter-spacing: 2rpx;
		}
	}
	
	.info-wrapper {
		margin-top: 60rpx;
		padding: 0 40rpx;
		color: #9596A3;
		.info {
			margin-top: 10rpx;
			letter-spacing: 2rpx;
			font-size: 28rpx;
		}
		.light {
			color: #fff;
		}
	}
	
	.footer {
		background: #404457;
		height: 100rpx;
		position: fixed;
		bottom: 0;
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 32rpx;
		color: #A0A1AB;
		.cancel {
			font-size: 26rpx;
			color: #fff;
			margin-left: 40rpx;
		}
		.right {
			display: flex;
			justify-content: flex-end;
			align-items: center;
			height: 100%;
		}
		.money {
			color: #00DA8A;
			margin-right: 20rpx;
		}
		.btn {
			color: #fff;
			padding: 0 60rpx;
			background: #00D388;
			height: 100%;
			display: flex;
			align-items: center;
		}
	}
</style>
